#include "sv/util/cmap.h"

#include "sv/util/logging.h"

namespace sv {

inline constexpr double Clamp01(double x) noexcept {
  return (x < 0.0) ? 0.0 : (x > 1.0) ? 1.0 : x;
}

ColorMap::ColorMap(std::string name, const std::vector<Eigen::Vector3d>& colors)
    : name_{std::move(name)}, data_{colors} {
  CHECK_GT(colors.size(), 1);
  step_ = 1.0 / (static_cast<int>(colors.size()) - 1);
}

Eigen::Vector3d ColorMap::GetRgb(double x) const noexcept {
  const double a = Clamp01(x) * (size() - 1);
  const double i = std::floor(a);
  const double s = a - i;
  const auto& c0 = data_.at(static_cast<size_t>(i));
  const auto& c1 = data_.at(static_cast<size_t>(std::ceil(a)));
  return c0 * (1.0 - s) + c1 * s;
}

std::string ColorMap::Repr() const {
  return fmt::format("ColorMap(name={}, size={})", name_, size());
}

ColorMap MakeCmapJet() {
  return {"jet",
          {{0.0, 0.0, 0.5},
           {0.0, 0.0, 1.0},
           {0.0, 0.5, 1.0},
           {0.0, 1.0, 1.0},
           {0.5, 1.0, 0.5},
           {1.0, 1.0, 0.0},
           {1.0, 0.5, 0.0},
           {1.0, 0.0, 0.0},
           {0.5, 0.0, 0.0}}};
}

ColorMap MakeCmapHeat() {
  return {"heat",
          {{0.0, 0.0, 1.0},
           {0.0, 1.0, 1.0},
           {0.0, 1.0, 0.0},
           {1.0, 1.0, 0.0},
           {1.0, 0.0, 0.0}}};
}

ColorMap MakeCmapTurbo() {
  return {"turbo", {{0.18995, 0.07176, 0.23217}, {0.19483, 0.08339, 0.26149},
                    {0.19956, 0.09498, 0.29024}, {0.20415, 0.10652, 0.31844},
                    {0.20860, 0.11802, 0.34607}, {0.21291, 0.12947, 0.37314},
                    {0.21708, 0.14087, 0.39964}, {0.22111, 0.15223, 0.42558},
                    {0.22500, 0.16354, 0.45096}, {0.22875, 0.17481, 0.47578},
                    {0.23236, 0.18603, 0.50004}, {0.23582, 0.19720, 0.52373},
                    {0.23915, 0.20833, 0.54686}, {0.24234, 0.21941, 0.56942},
                    {0.24539, 0.23044, 0.59142}, {0.24830, 0.24143, 0.61286},
                    {0.25107, 0.25237, 0.63374}, {0.25369, 0.26327, 0.65406},
                    {0.25618, 0.27412, 0.67381}, {0.25853, 0.28492, 0.69300},
                    {0.26074, 0.29568, 0.71162}, {0.26280, 0.30639, 0.72968},
                    {0.26473, 0.31706, 0.74718}, {0.26652, 0.32768, 0.76412},
                    {0.26816, 0.33825, 0.78050}, {0.26967, 0.34878, 0.79631},
                    {0.27103, 0.35926, 0.81156}, {0.27226, 0.36970, 0.82624},
                    {0.27334, 0.38008, 0.84037}, {0.27429, 0.39043, 0.85393},
                    {0.27509, 0.40072, 0.86692}, {0.27576, 0.41097, 0.87936},
                    {0.27628, 0.42118, 0.89123}, {0.27667, 0.43134, 0.90254},
                    {0.27691, 0.44145, 0.91328}, {0.27701, 0.45152, 0.92347},
                    {0.27698, 0.46153, 0.93309}, {0.27680, 0.47151, 0.94214},
                    {0.27648, 0.48144, 0.95064}, {0.27603, 0.49132, 0.95857},
                    {0.27543, 0.50115, 0.96594}, {0.27469, 0.51094, 0.97275},
                    {0.27381, 0.52069, 0.97899}, {0.27273, 0.53040, 0.98461},
                    {0.27106, 0.54015, 0.98930}, {0.26878, 0.54995, 0.99303},
                    {0.26592, 0.55979, 0.99583}, {0.26252, 0.56967, 0.99773},
                    {0.25862, 0.57958, 0.99876}, {0.25425, 0.58950, 0.99896},
                    {0.24946, 0.59943, 0.99835}, {0.24427, 0.60937, 0.99697},
                    {0.23874, 0.61931, 0.99485}, {0.23288, 0.62923, 0.99202},
                    {0.22676, 0.63913, 0.98851}, {0.22039, 0.64901, 0.98436},
                    {0.21382, 0.65886, 0.97959}, {0.20708, 0.66866, 0.97423},
                    {0.20021, 0.67842, 0.96833}, {0.19326, 0.68812, 0.96190},
                    {0.18625, 0.69775, 0.95498}, {0.17923, 0.70732, 0.94761},
                    {0.17223, 0.71680, 0.93981}, {0.16529, 0.72620, 0.93161},
                    {0.15844, 0.73551, 0.92305}, {0.15173, 0.74472, 0.91416},
                    {0.14519, 0.75381, 0.90496}, {0.13886, 0.76279, 0.89550},
                    {0.13278, 0.77165, 0.88580}, {0.12698, 0.78037, 0.87590},
                    {0.12151, 0.78896, 0.86581}, {0.11639, 0.79740, 0.85559},
                    {0.11167, 0.80569, 0.84525}, {0.10738, 0.81381, 0.83484},
                    {0.10357, 0.82177, 0.82437}, {0.10026, 0.82955, 0.81389},
                    {0.09750, 0.83714, 0.80342}, {0.09532, 0.84455, 0.79299},
                    {0.09377, 0.85175, 0.78264}, {0.09287, 0.85875, 0.77240},
                    {0.09267, 0.86554, 0.76230}, {0.09320, 0.87211, 0.75237},
                    {0.09451, 0.87844, 0.74265}, {0.09662, 0.88454, 0.73316},
                    {0.09958, 0.89040, 0.72393}, {0.10342, 0.89600, 0.71500},
                    {0.10815, 0.90142, 0.70599}, {0.11374, 0.90673, 0.69651},
                    {0.12014, 0.91193, 0.68660}, {0.12733, 0.91701, 0.67627},
                    {0.13526, 0.92197, 0.66556}, {0.14391, 0.92680, 0.65448},
                    {0.15323, 0.93151, 0.64308}, {0.16319, 0.93609, 0.63137},
                    {0.17377, 0.94053, 0.61938}, {0.18491, 0.94484, 0.60713},
                    {0.19659, 0.94901, 0.59466}, {0.20877, 0.95304, 0.58199},
                    {0.22142, 0.95692, 0.56914}, {0.23449, 0.96065, 0.55614},
                    {0.24797, 0.96423, 0.54303}, {0.26180, 0.96765, 0.52981},
                    {0.27597, 0.97092, 0.51653}, {0.29042, 0.97403, 0.50321},
                    {0.30513, 0.97697, 0.48987}, {0.32006, 0.97974, 0.47654},
                    {0.33517, 0.98234, 0.46325}, {0.35043, 0.98477, 0.45002},
                    {0.36581, 0.98702, 0.43688}, {0.38127, 0.98909, 0.42386},
                    {0.39678, 0.99098, 0.41098}, {0.41229, 0.99268, 0.39826},
                    {0.42778, 0.99419, 0.38575}, {0.44321, 0.99551, 0.37345},
                    {0.45854, 0.99663, 0.36140}, {0.47375, 0.99755, 0.34963},
                    {0.48879, 0.99828, 0.33816}, {0.50362, 0.99879, 0.32701},
                    {0.51822, 0.99910, 0.31622}, {0.53255, 0.99919, 0.30581},
                    {0.54658, 0.99907, 0.29581}, {0.56026, 0.99873, 0.28623},
                    {0.57357, 0.99817, 0.27712}, {0.58646, 0.99739, 0.26849},
                    {0.59891, 0.99638, 0.26038}, {0.61088, 0.99514, 0.25280},
                    {0.62233, 0.99366, 0.24579}, {0.63323, 0.99195, 0.23937},
                    {0.64362, 0.98999, 0.23356}, {0.65394, 0.98775, 0.22835},
                    {0.66428, 0.98524, 0.22370}, {0.67462, 0.98246, 0.21960},
                    {0.68494, 0.97941, 0.21602}, {0.69525, 0.97610, 0.21294},
                    {0.70553, 0.97255, 0.21032}, {0.71577, 0.96875, 0.20815},
                    {0.72596, 0.96470, 0.20640}, {0.73610, 0.96043, 0.20504},
                    {0.74617, 0.95593, 0.20406}, {0.75617, 0.95121, 0.20343},
                    {0.76608, 0.94627, 0.20311}, {0.77591, 0.94113, 0.20310},
                    {0.78563, 0.93579, 0.20336}, {0.79524, 0.93025, 0.20386},
                    {0.80473, 0.92452, 0.20459}, {0.81410, 0.91861, 0.20552},
                    {0.82333, 0.91253, 0.20663}, {0.83241, 0.90627, 0.20788},
                    {0.84133, 0.89986, 0.20926}, {0.85010, 0.89328, 0.21074},
                    {0.85868, 0.88655, 0.21230}, {0.86709, 0.87968, 0.21391},
                    {0.87530, 0.87267, 0.21555}, {0.88331, 0.86553, 0.21719},
                    {0.89112, 0.85826, 0.21880}, {0.89870, 0.85087, 0.22038},
                    {0.90605, 0.84337, 0.22188}, {0.91317, 0.83576, 0.22328},
                    {0.92004, 0.82806, 0.22456}, {0.92666, 0.82025, 0.22570},
                    {0.93301, 0.81236, 0.22667}, {0.93909, 0.80439, 0.22744},
                    {0.94489, 0.79634, 0.22800}, {0.95039, 0.78823, 0.22831},
                    {0.95560, 0.78005, 0.22836}, {0.96049, 0.77181, 0.22811},
                    {0.96507, 0.76352, 0.22754}, {0.96931, 0.75519, 0.22663},
                    {0.97323, 0.74682, 0.22536}, {0.97679, 0.73842, 0.22369},
                    {0.98000, 0.73000, 0.22161}, {0.98289, 0.72140, 0.21918},
                    {0.98549, 0.71250, 0.21650}, {0.98781, 0.70330, 0.21358},
                    {0.98986, 0.69382, 0.21043}, {0.99163, 0.68408, 0.20706},
                    {0.99314, 0.67408, 0.20348}, {0.99438, 0.66386, 0.19971},
                    {0.99535, 0.65341, 0.19577}, {0.99607, 0.64277, 0.19165},
                    {0.99654, 0.63193, 0.18738}, {0.99675, 0.62093, 0.18297},
                    {0.99672, 0.60977, 0.17842}, {0.99644, 0.59846, 0.17376},
                    {0.99593, 0.58703, 0.16899}, {0.99517, 0.57549, 0.16412},
                    {0.99419, 0.56386, 0.15918}, {0.99297, 0.55214, 0.15417},
                    {0.99153, 0.54036, 0.14910}, {0.98987, 0.52854, 0.14398},
                    {0.98799, 0.51667, 0.13883}, {0.98590, 0.50479, 0.13367},
                    {0.98360, 0.49291, 0.12849}, {0.98108, 0.48104, 0.12332},
                    {0.97837, 0.46920, 0.11817}, {0.97545, 0.45740, 0.11305},
                    {0.97234, 0.44565, 0.10797}, {0.96904, 0.43399, 0.10294},
                    {0.96555, 0.42241, 0.09798}, {0.96187, 0.41093, 0.09310},
                    {0.95801, 0.39958, 0.08831}, {0.95398, 0.38836, 0.08362},
                    {0.94977, 0.37729, 0.07905}, {0.94538, 0.36638, 0.07461},
                    {0.94084, 0.35566, 0.07031}, {0.93612, 0.34513, 0.06616},
                    {0.93125, 0.33482, 0.06218}, {0.92623, 0.32473, 0.05837},
                    {0.92105, 0.31489, 0.05475}, {0.91572, 0.30530, 0.05134},
                    {0.91024, 0.29599, 0.04814}, {0.90463, 0.28696, 0.04516},
                    {0.89888, 0.27824, 0.04243}, {0.89298, 0.26981, 0.03993},
                    {0.88691, 0.26152, 0.03753}, {0.88066, 0.25334, 0.03521},
                    {0.87422, 0.24526, 0.03297}, {0.86760, 0.23730, 0.03082},
                    {0.86079, 0.22945, 0.02875}, {0.85380, 0.22170, 0.02677},
                    {0.84662, 0.21407, 0.02487}, {0.83926, 0.20654, 0.02305},
                    {0.83172, 0.19912, 0.02131}, {0.82399, 0.19182, 0.01966},
                    {0.81608, 0.18462, 0.01809}, {0.80799, 0.17753, 0.01660},
                    {0.79971, 0.17055, 0.01520}, {0.79125, 0.16368, 0.01387},
                    {0.78260, 0.15693, 0.01264}, {0.77377, 0.15028, 0.01148},
                    {0.76476, 0.14374, 0.01041}, {0.75556, 0.13731, 0.00942},
                    {0.74617, 0.13098, 0.00851}, {0.73661, 0.12477, 0.00769},
                    {0.72686, 0.11867, 0.00695}, {0.71692, 0.11268, 0.00629},
                    {0.70680, 0.10680, 0.00571}, {0.69650, 0.10102, 0.00522},
                    {0.68602, 0.09536, 0.00481}, {0.67535, 0.08980, 0.00449},
                    {0.66449, 0.08436, 0.00424}, {0.65345, 0.07902, 0.00408},
                    {0.64223, 0.07380, 0.00401}, {0.63082, 0.06868, 0.00401},
                    {0.61923, 0.06367, 0.00410}, {0.60746, 0.05878, 0.00427},
                    {0.59550, 0.05399, 0.00453}, {0.58336, 0.04931, 0.00486},
                    {0.57103, 0.04474, 0.00529}, {0.55852, 0.04028, 0.00579},
                    {0.54583, 0.03593, 0.00638}, {0.53295, 0.03169, 0.00705},
                    {0.51989, 0.02756, 0.00780}, {0.50664, 0.02354, 0.00863},
                    {0.49321, 0.01963, 0.00955}, {0.47960, 0.01583, 0.01055}}

  };
}

ColorMap MakeCmapPlasma() {
  return {"plasma",
          {{0.050383, 0.029803, 0.527975}, {0.063536, 0.028426, 0.533124},
           {0.075353, 0.027206, 0.538007}, {0.086222, 0.026125, 0.542658},
           {0.096379, 0.025165, 0.547103}, {0.105980, 0.024309, 0.551368},
           {0.115124, 0.023556, 0.555468}, {0.123903, 0.022878, 0.559423},
           {0.132381, 0.022258, 0.563250}, {0.140603, 0.021687, 0.566959},
           {0.148607, 0.021154, 0.570562}, {0.156421, 0.020651, 0.574065},
           {0.164070, 0.020171, 0.577478}, {0.171574, 0.019706, 0.580806},
           {0.178950, 0.019252, 0.584054}, {0.186213, 0.018803, 0.587228},
           {0.193374, 0.018354, 0.590330}, {0.200445, 0.017902, 0.593364},
           {0.207435, 0.017442, 0.596333}, {0.214350, 0.016973, 0.599239},
           {0.221197, 0.016497, 0.602083}, {0.227983, 0.016007, 0.604867},
           {0.234715, 0.015502, 0.607592}, {0.241396, 0.014979, 0.610259},
           {0.248032, 0.014439, 0.612868}, {0.254627, 0.013882, 0.615419},
           {0.261183, 0.013308, 0.617911}, {0.267703, 0.012716, 0.620346},
           {0.274191, 0.012109, 0.622722}, {0.280648, 0.011488, 0.625038},
           {0.287076, 0.010855, 0.627295}, {0.293478, 0.010213, 0.629490},
           {0.299855, 0.009561, 0.631624}, {0.306210, 0.008902, 0.633694},
           {0.312543, 0.008239, 0.635700}, {0.318856, 0.007576, 0.637640},
           {0.325150, 0.006915, 0.639512}, {0.331426, 0.006261, 0.641316},
           {0.337683, 0.005618, 0.643049}, {0.343925, 0.004991, 0.644710},
           {0.350150, 0.004382, 0.646298}, {0.356359, 0.003798, 0.647810},
           {0.362553, 0.003243, 0.649245}, {0.368733, 0.002724, 0.650601},
           {0.374897, 0.002245, 0.651876}, {0.381047, 0.001814, 0.653068},
           {0.387183, 0.001434, 0.654177}, {0.393304, 0.001114, 0.655199},
           {0.399411, 0.000859, 0.656133}, {0.405503, 0.000678, 0.656977},
           {0.411580, 0.000577, 0.657730}, {0.417642, 0.000564, 0.658390},
           {0.423689, 0.000646, 0.658956}, {0.429719, 0.000831, 0.659425},
           {0.435734, 0.001127, 0.659797}, {0.441732, 0.001540, 0.660069},
           {0.447714, 0.002080, 0.660240}, {0.453677, 0.002755, 0.660310},
           {0.459623, 0.003574, 0.660277}, {0.465550, 0.004545, 0.660139},
           {0.471457, 0.005678, 0.659897}, {0.477344, 0.006980, 0.659549},
           {0.483210, 0.008460, 0.659095}, {0.489055, 0.010127, 0.658534},
           {0.494877, 0.011990, 0.657865}, {0.500678, 0.014055, 0.657088},
           {0.506454, 0.016333, 0.656202}, {0.512206, 0.018833, 0.655209},
           {0.517933, 0.021563, 0.654109}, {0.523633, 0.024532, 0.652901},
           {0.529306, 0.027747, 0.651586}, {0.534952, 0.031217, 0.650165},
           {0.540570, 0.034950, 0.648640}, {0.546157, 0.038954, 0.647010},
           {0.551715, 0.043136, 0.645277}, {0.557243, 0.047331, 0.643443},
           {0.562738, 0.051545, 0.641509}, {0.568201, 0.055778, 0.639477},
           {0.573632, 0.060028, 0.637349}, {0.579029, 0.064296, 0.635126},
           {0.584391, 0.068579, 0.632812}, {0.589719, 0.072878, 0.630408},
           {0.595011, 0.077190, 0.627917}, {0.600266, 0.081516, 0.625342},
           {0.605485, 0.085854, 0.622686}, {0.610667, 0.090204, 0.619951},
           {0.615812, 0.094564, 0.617140}, {0.620919, 0.098934, 0.614257},
           {0.625987, 0.103312, 0.611305}, {0.631017, 0.107699, 0.608287},
           {0.636008, 0.112092, 0.605205}, {0.640959, 0.116492, 0.602065},
           {0.645872, 0.120898, 0.598867}, {0.650746, 0.125309, 0.595617},
           {0.655580, 0.129725, 0.592317}, {0.660374, 0.134144, 0.588971},
           {0.665129, 0.138566, 0.585582}, {0.669845, 0.142992, 0.582154},
           {0.674522, 0.147419, 0.578688}, {0.679160, 0.151848, 0.575189},
           {0.683758, 0.156278, 0.571660}, {0.688318, 0.160709, 0.568103},
           {0.692840, 0.165141, 0.564522}, {0.697324, 0.169573, 0.560919},
           {0.701769, 0.174005, 0.557296}, {0.706178, 0.178437, 0.553657},
           {0.710549, 0.182868, 0.550004}, {0.714883, 0.187299, 0.546338},
           {0.719181, 0.191729, 0.542663}, {0.723444, 0.196158, 0.538981},
           {0.727670, 0.200586, 0.535293}, {0.731862, 0.205013, 0.531601},
           {0.736019, 0.209439, 0.527908}, {0.740143, 0.213864, 0.524216},
           {0.744232, 0.218288, 0.520524}, {0.748289, 0.222711, 0.516834},
           {0.752312, 0.227133, 0.513149}, {0.756304, 0.231555, 0.509468},
           {0.760264, 0.235976, 0.505794}, {0.764193, 0.240396, 0.502126},
           {0.768090, 0.244817, 0.498465}, {0.771958, 0.249237, 0.494813},
           {0.775796, 0.253658, 0.491171}, {0.779604, 0.258078, 0.487539},
           {0.783383, 0.262500, 0.483918}, {0.787133, 0.266922, 0.480307},
           {0.790855, 0.271345, 0.476706}, {0.794549, 0.275770, 0.473117},
           {0.798216, 0.280197, 0.469538}, {0.801855, 0.284626, 0.465971},
           {0.805467, 0.289057, 0.462415}, {0.809052, 0.293491, 0.458870},
           {0.812612, 0.297928, 0.455338}, {0.816144, 0.302368, 0.451816},
           {0.819651, 0.306812, 0.448306}, {0.823132, 0.311261, 0.444806},
           {0.826588, 0.315714, 0.441316}, {0.830018, 0.320172, 0.437836},
           {0.833422, 0.324635, 0.434366}, {0.836801, 0.329105, 0.430905},
           {0.840155, 0.333580, 0.427455}, {0.843484, 0.338062, 0.424013},
           {0.846788, 0.342551, 0.420579}, {0.850066, 0.347048, 0.417153},
           {0.853319, 0.351553, 0.413734}, {0.856547, 0.356066, 0.410322},
           {0.859750, 0.360588, 0.406917}, {0.862927, 0.365119, 0.403519},
           {0.866078, 0.369660, 0.400126}, {0.869203, 0.374212, 0.396738},
           {0.872303, 0.378774, 0.393355}, {0.875376, 0.383347, 0.389976},
           {0.878423, 0.387932, 0.386600}, {0.881443, 0.392529, 0.383229},
           {0.884436, 0.397139, 0.379860}, {0.887402, 0.401762, 0.376494},
           {0.890340, 0.406398, 0.373130}, {0.893250, 0.411048, 0.369768},
           {0.896131, 0.415712, 0.366407}, {0.898984, 0.420392, 0.363047},
           {0.901807, 0.425087, 0.359688}, {0.904601, 0.429797, 0.356329},
           {0.907365, 0.434524, 0.352970}, {0.910098, 0.439268, 0.349610},
           {0.912800, 0.444029, 0.346251}, {0.915471, 0.448807, 0.342890},
           {0.918109, 0.453603, 0.339529}, {0.920714, 0.458417, 0.336166},
           {0.923287, 0.463251, 0.332801}, {0.925825, 0.468103, 0.329435},
           {0.928329, 0.472975, 0.326067}, {0.930798, 0.477867, 0.322697},
           {0.933232, 0.482780, 0.319325}, {0.935630, 0.487712, 0.315952},
           {0.937990, 0.492667, 0.312575}, {0.940313, 0.497642, 0.309197},
           {0.942598, 0.502639, 0.305816}, {0.944844, 0.507658, 0.302433},
           {0.947051, 0.512699, 0.299049}, {0.949217, 0.517763, 0.295662},
           {0.951344, 0.522850, 0.292275}, {0.953428, 0.527960, 0.288883},
           {0.955470, 0.533093, 0.285490}, {0.957469, 0.538250, 0.282096},
           {0.959424, 0.543431, 0.278701}, {0.961336, 0.548636, 0.275305},
           {0.963203, 0.553865, 0.271909}, {0.965024, 0.559118, 0.268513},
           {0.966798, 0.564396, 0.265118}, {0.968526, 0.569700, 0.261721},
           {0.970205, 0.575028, 0.258325}, {0.971835, 0.580382, 0.254931},
           {0.973416, 0.585761, 0.251540}, {0.974947, 0.591165, 0.248151},
           {0.976428, 0.596595, 0.244767}, {0.977856, 0.602051, 0.241387},
           {0.979233, 0.607532, 0.238013}, {0.980556, 0.613039, 0.234646},
           {0.981826, 0.618572, 0.231287}, {0.983041, 0.624131, 0.227937},
           {0.984199, 0.629718, 0.224595}, {0.985301, 0.635330, 0.221265},
           {0.986345, 0.640969, 0.217948}, {0.987332, 0.646633, 0.214648},
           {0.988260, 0.652325, 0.211364}, {0.989128, 0.658043, 0.208100},
           {0.989935, 0.663787, 0.204859}, {0.990681, 0.669558, 0.201642},
           {0.991365, 0.675355, 0.198453}, {0.991985, 0.681179, 0.195295},
           {0.992541, 0.687030, 0.192170}, {0.993032, 0.692907, 0.189084},
           {0.993456, 0.698810, 0.186041}, {0.993814, 0.704741, 0.183043},
           {0.994103, 0.710698, 0.180097}, {0.994324, 0.716681, 0.177208},
           {0.994474, 0.722691, 0.174381}, {0.994553, 0.728728, 0.171622},
           {0.994561, 0.734791, 0.168938}, {0.994495, 0.740880, 0.166335},
           {0.994355, 0.746995, 0.163821}, {0.994141, 0.753137, 0.161404},
           {0.993851, 0.759304, 0.159092}, {0.993482, 0.765499, 0.156891},
           {0.993033, 0.771720, 0.154808}, {0.992505, 0.777967, 0.152855},
           {0.991897, 0.784239, 0.151042}, {0.991209, 0.790537, 0.149377},
           {0.990439, 0.796859, 0.147870}, {0.989587, 0.803205, 0.146529},
           {0.988648, 0.809579, 0.145357}, {0.987621, 0.815978, 0.144363},
           {0.986509, 0.822401, 0.143557}, {0.985314, 0.828846, 0.142945},
           {0.984031, 0.835315, 0.142528}, {0.982653, 0.841812, 0.142303},
           {0.981190, 0.848329, 0.142279}, {0.979644, 0.854866, 0.142453},
           {0.977995, 0.861432, 0.142808}, {0.976265, 0.868016, 0.143351},
           {0.974443, 0.874622, 0.144061}, {0.972530, 0.881250, 0.144923},
           {0.970533, 0.887896, 0.145919}, {0.968443, 0.894564, 0.147014},
           {0.966271, 0.901249, 0.148180}, {0.964021, 0.907950, 0.149370},
           {0.961681, 0.914672, 0.150520}, {0.959276, 0.921407, 0.151566},
           {0.956808, 0.928152, 0.152409}, {0.954287, 0.934908, 0.152921},
           {0.951726, 0.941671, 0.152925}, {0.949151, 0.948435, 0.152178},
           {0.946602, 0.955190, 0.150328}, {0.944152, 0.961916, 0.146861},
           {0.941896, 0.968590, 0.140956}, {0.940015, 0.975158, 0.131326}}};
}

ColorMap GetColorMap(std::string_view name) {
  if (name == "jet") return MakeCmapJet();
  if (name == "heat") return MakeCmapHeat();
  if (name == "turbo") return MakeCmapTurbo();
  if (name == "plasma") return MakeCmapPlasma();

  // Default is jet
  return MakeCmapJet();
}

}  // namespace sv
